<?php
class ActivityConf_createXmlByExcel {
	function createXmlByExcel($excelPath, $activityInfo, $fileName, $sheet = '0') {
		
		$gameEn = $activityInfo['activityNameEn'];
		
		$xmlDir = ROOT_PATH . "/activityFiles/xml/{$gameEn}/";
		
		$xmlFileName  = $activityInfo['xmlLua'][$fileName]['xml'];
		
		// 生成xml路径
		$xmlPath = $xmlDir . $xmlFileName;
			
		$dataArr  = MooObj::get('Control_ExcelConfMaker_Excel')->read($excelPath, 'UTF-8', $sheet, true);
		
		// 路径不存在则创建目录
		if(!MooFile::isExists($xmlDir)) {
			MooFile::mkDir($xmlDir);
		}
		
		// 删除第lua注释
		unset($dataArr[1]);
	
		// 1 代表xml 2代表lua 和 xml 0 代表lua
		$dataArr = MooObj::get('ActivityConf')->formatExcelData($dataArr, "xml");
		
		sort($dataArr);
		
		// 生成xml
		$createXmlRes = MooXml::createXml($xmlPath, $dataArr);
		
		if($createXmlRes) {
			return array(true, $xmlPath);
		} else {
			return array(false, 0);
		}
		
	}
}